package com.app.qbake.module.mine.adapter.delegate;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.wind.base.adapter.BaseAdapterDelegate;
import com.wind.base.adapter.DisplayItem;
import com.wind.base.utils.ViewInflater;
import com.wind.data.square.bean.Goods;
import com.app.qbake.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class CollectGoodsDelegate extends BaseAdapterDelegate<CollectGoodsDelegate.ViewHolder> {


    public CollectGoodsDelegate(Activity activity, int layoutRes) {
        super(activity, layoutRes);
    }

    @Override
    protected ViewHolder onCreateViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    protected boolean isForViewType(@NonNull List<DisplayItem> items, int position) {
        return true;
    }

    @Override
    protected void onBindViewHolder(@NonNull List<DisplayItem> items, int position, @NonNull RecyclerView.ViewHolder holder, @NonNull List<Object> payloads) {
        Goods goods= (Goods) items.get(position);
        ViewHolder vh= (ViewHolder) holder;
        ViewInflater.inflateImage(vh.iv,goods.getImages_url().get(0));
        ViewInflater.inflateText(vh.tv_desc,goods.getUserName());
        ViewInflater.inflateText(vh.tv_price,"￥"+goods.getPrice());
    }

    static class ViewHolder extends RecyclerView.ViewHolder{

        @BindView(R.id.iv)
        ImageView iv;

        @BindView(R.id.tv_desc)
        TextView tv_desc;

        @BindView(R.id.tv_price)
        TextView tv_price;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
